home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / rpm / argv.h next >
Encoding:
C/C++ Source or Header  |  2008-10-22  |  3.3 KB  |  159 lines

  1. #ifndef _H_ARGV_
  2. #define    _H_ARGV_
  3.  
  4. /** \ingroup rpmio
  5.  * \file rpmio/argv.h
  6.  */
  7.  
  8. typedef    const char * ARGstr_t;
  9. typedef ARGstr_t * ARGV_t;
  10.  
  11. typedef    int * ARGint_t;
  12. struct ARGI_s {
  13.     unsigned nvals;
  14.     ARGint_t vals;
  15. };
  16. typedef    struct ARGI_s * ARGI_t;
  17.  
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21.  
  22. /**
  23.  * Print argv array elements.
  24.  * @param msg        output message prefix (or NULL)
  25.  * @param argv        argv array
  26.  * @param fp        output file handle (NULL uses stderr)
  27.  */
  28. void argvPrint(const char * msg, ARGV_t argv, FILE * fp)
  29.     /*@globals fileSystem @*/
  30.     /*@modifies *fp, fileSystem @*/;
  31.  
  32. /**
  33.  * Destroy an argi array.
  34.  * @param argi        argi array
  35.  * @return        NULL always
  36.  */
  37. /*@null@*/
  38. ARGI_t argiFree(/*@only@*/ /*@null@*/ ARGI_t argi)
  39.     /*@modifies argi @*/;
  40.  
  41. /**
  42.  * Destroy an argv array.
  43.  * @param argv        argv array
  44.  * @return        NULL always
  45.  */
  46. /*@null@*/
  47. ARGV_t argvFree(/*@only@*/ /*@null@*/ ARGV_t argv)
  48.     /*@modifies argv @*/;
  49.  
  50. /**
  51.  * Return no. of elements in argi array.
  52.  * @param argi        argi array
  53.  * @return        no. of elements
  54.  */
  55. int argiCount(/*@null@*/ const ARGI_t argi)
  56.     /*@*/;
  57.  
  58. /**
  59.  * Return data from argi array.
  60.  * @param argi        argi array
  61.  * @return        argi array data address
  62.  */
  63. /*@null@*/
  64. const ARGint_t argiData(/*@null@*/ const ARGI_t argi)
  65.     /*@*/;
  66.  
  67. /**
  68.  * Return no. of elements in argv array.
  69.  * @param argv        argv array
  70.  * @return        no. of elements
  71.  */
  72. int argvCount(/*@null@*/ const ARGV_t argv)
  73.     /*@*/;
  74.  
  75. /**
  76.  * Return data from argv array.
  77.  * @param argv        argv array
  78.  * @return        argv array data address
  79.  */
  80. /*@null@*/
  81. const ARGV_t argvData(/*@null@*/ const ARGV_t argv)
  82.     /*@*/;
  83.  
  84. /**
  85.  * Compare argv arrays (qsort/bsearch).
  86.  * @param a        1st instance address
  87.  * @param b        2nd instance address
  88.  * @return        result of comparison
  89.  */
  90. /*@-exportlocal@*/
  91. int argvCmp(const void * a, const void * b)
  92.     /*@*/;
  93. /*@=exportlocal@*/
  94.  
  95. /**
  96.  * Sort an argv array.
  97.  * @param argv        argv array
  98.  * @param compar    strcmp-like comparison function, or NULL for argvCmp()
  99.  * @return        0 always
  100.  */
  101. int argvSort(ARGV_t argv, int (*compar)(const void *, const void *))
  102.     /*@modifies *argv @*/;
  103.  
  104. /**
  105.  * Find an element in an argv array.
  106.  * @param argv        argv array
  107.  * @param val        string to find
  108.  * @param compar    strcmp-like comparison function, or NULL for argvCmp()
  109.  * @return        found string (NULL on failure)
  110.  */
  111. /*@dependent@*/ /*@null@*/
  112. ARGV_t argvSearch(ARGV_t argv, ARGstr_t val,
  113.         int (*compar)(const void *, const void *))
  114.     /*@*/;
  115.  
  116. /**
  117.  * Add an int to an argi array.
  118.  * @retval *argip    argi array
  119.  * @param ix        argi array index (or -1 to append)
  120.  * @param val        int arg to add
  121.  * @return        0 always
  122.  */
  123. int argiAdd(/*@out@*/ ARGI_t * argip, int ix, int val)
  124.     /*@modifies *argip @*/;
  125.  
  126. /**
  127.  * Add a string to an argv array.
  128.  * @retval *argvp    argv array
  129.  * @param val        string arg to append
  130.  * @return        0 always
  131.  */
  132. int argvAdd(/*@out@*/ ARGV_t * argvp, ARGstr_t val)
  133.     /*@modifies *argvp @*/;
  134.  
  135. /**
  136.  * Append one argv array to another.
  137.  * @retval *argvp    argv array
  138.  * @param av        argv array to append
  139.  * @return        0 always
  140.  */
  141. int argvAppend(/*@out@*/ ARGV_t * argvp, const ARGV_t av)
  142.     /*@modifies *argvp @*/;
  143.  
  144. /**
  145.  * Split a string into an argv array.
  146.  * @retval *argvp    argv array
  147.  * @param str        string arg to split
  148.  * @param seps        seperator characters
  149.  * @return        0 always
  150.  */
  151. int argvSplit(ARGV_t * argvp, const char * str, const char * seps)
  152.     /*@modifies *argvp @*/;
  153.  
  154. #ifdef __cplusplus
  155. }
  156. #endif
  157.  
  158. #endif /* _H_ARGV_ */
  159.